# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from ingenium.models import *
from publicacoes.models import *
from django.contrib.localflavor.br.forms import BRCPFField, BRCNPJField, BRPhoneNumberField, BRZipCodeField
from django import forms
from django.contrib.localflavor.br.br_states import STATE_CHOICES
from forms import *
from models import *
from django.contrib.admin import widgets
from django.forms.fields import DateField, ChoiceField, MultipleChoiceField
from django.forms.widgets import RadioSelect, CheckboxSelectMultiple
from django.http import HttpResponseRedirect
#from emencia.django.newsletter.models import Contact
from django.core.mail import send_mail
from django.utils.safestring import mark_safe

#class emailForm(forms.ModelForm):
 #   class Meta:
  #      model = Contact
   #     exclude = ('first_name', 'last_name', 'subscriber', 'valid', 'tester', 'tags', 'object_id', 'content_object', 'content_type')

class HorizRadioRenderer(forms.RadioSelect.renderer):
    def render(self):
        return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))


class empresaForm(forms.ModelForm):
    class Meta:
        model = empresa

#Informações Pessoais
    nome = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[minSize[8]] input-large'}))
    email = forms.EmailField(max_length=255, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    cpf = BRCPFField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cpf'}))
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    sexo = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=SEXO_CHOICES)
    atuacao =  forms.CharField(max_length=2,widget=forms.Select(choices=ATUACAO_C, attrs={'class':'validate[required] select-medium'}))
    cargo = forms.CharField(max_length =50, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
#Dados da Empresa
    nome_fantasia = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    razao = forms.CharField(max_length=50, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    cnpj = BRCNPJField(widget=forms.TextInput(attrs={'class':"validate[required] input-small cnpj"}))
    foto = forms.ImageField(required=False)
    telefone1 = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    origem = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices = ORIGEM_C)
    site = forms.URLField(required=False, widget=forms.TextInput(attrs={'class':'input-large'}))
    email1 = forms.EmailField(required=False, max_length=255, widget=forms.TextInput(attrs={'class':'input-medium'}))
    nacionalidade = forms.CharField(max_length=40, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    cep = BRZipCodeField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cep'}))
    estado = forms.ChoiceField(choices = STATE_CHOICES, widget=forms.Select(attrs={'class':'validate[required] select-medium'}))
    cidade = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    endereco = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    bairro = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    complemento = forms.CharField(widget=forms.TextInput(attrs={'class':'input-large'}),max_length=255, required=False)
    ramo = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-medium'}))
    tipodeempresa = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=TIPEMP_C)
    descricao = forms.CharField(widget=forms.Textarea(attrs={'class':'textarea-large'}))
    quantFuncionario = forms.IntegerField(max_value=10000, widget=forms.TextInput(attrs={'class':"validate[required] input-small"}))
#Cadastro
    username = forms.CharField(max_length = 255, widget = forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    senha = forms.CharField(max_length = 30, widget = forms.PasswordInput(attrs={'class':'input-medium validate[required]','minlength':'5'}))
    
    def clean_username(self):
        if User.objects.filter(
            username=self.cleaned_data['username'],
            ).count():
            raise forms.ValidationError('Ja existe um usuario com este login')

        return self.cleaned_data['username']

    def save(self, commit=False, force_inert=True, force_update=True):
        emrpesa = super(empresaForm, self).save()

        if commit:
            empresa.save()

        return empresa


class usuarioForm(forms.ModelForm):
    class Meta:
        model = usuario

#Informações Pessoais	
    nome = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    nacionalidade = forms.CharField(max_length=40, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    nascimento = forms.DateField(widget=forms.DateTimeInput(attrs={'class':'validate[required] input-small date'}))
    cpf = BRCPFField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cpf'})) 
    rg = forms.CharField(max_length=15, required=False, widget=forms.TextInput(attrs={'class':'input-small'}))
    est_Civil = forms.CharField(max_length=1,widget=forms.Select(choices=ESTADOCIVIL_C, attrs={'class':'validate[required] select-medium'}))
    sexo = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=SEXO_CHOICES)
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    telefone2 = BRPhoneNumberField(required=False, widget=forms.TextInput(attrs={'class':'input-small tel'}))
    cep = BRZipCodeField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cep'}))
    site = forms.URLField(required=False, widget=forms.TextInput(attrs={'class':'input-large'}))
    foto = forms.ImageField(required=False)
    cidade = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    estado = forms.ChoiceField(choices = STATE_CHOICES, widget=forms.Select(attrs={'class':'validate[required] select-medium'}))
    rua = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    bairro = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    complemento = forms.CharField(widget=forms.TextInput(attrs={'class':'input-large'}),max_length=255, required=False)
#Interesses Profissionais
    areaes = forms.ModelMultipleChoiceField(queryset=areavaga.objects.all(), widget=CheckboxSelectMultiple(attrs={'class':'validate[required]'}))
    pret_salario = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-medium'}), choices=SALARIO_C)
    cargointeresse = forms.CharField(max_length =75, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    tipoperfil = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=TIPOPERFIL_C)
#Pesquisa
    conhecimento = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-large'}), choices=CONHECIMENTO_C)
    conhecimento2 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    pesquisa1 = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-large'}), choices=PESQ_C)
    conhecimento3 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
#Cadastro
    email = forms.EmailField(max_length=255, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    senha  = forms.CharField(max_length = 30, widget = forms.PasswordInput(attrs={'class':'required input-medium validate[required]','minlength':'5'}))

#Parte cadastro
#Graduacao
    nivel = forms.CharField(required=False, max_length=1,widget=forms.Select(choices=NIVEL_C, attrs={'class':'select-medium'}))
    instituicao = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    ano_conclusao = forms.CharField(required=False,max_length=8, widget=forms.TextInput(attrs={'class':'input-small date2'}))
    nivel1 = forms.CharField(required=False,max_length=1,widget=forms.Select(choices=NIVEL_C, attrs={'class':'select-medium'}))
    instituicao1 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso1 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    ano_conclusao1 = forms.CharField(required=False,max_length=8, widget=forms.TextInput(attrs={'class':'input-small date2'}))
    nivel2 = forms.CharField(required=False,max_length=1,widget=forms.Select(choices=NIVEL_C, attrs={'class':'select-medium'}))
    instituicao2 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso2 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    ano_conclusao2 = forms.CharField(required=False,max_length=8, widget=forms.TextInput(attrs={'class':'input-small date2'}))
    niveli = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}), choices=NIVELLI_C)
    nivele = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}), choices=NIVELLI_C)
    nivelidioma = forms.CharField(required=False,max_length=20, widget=forms.TextInput(attrs={'class':'input-small'}))
    niveloutro = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer), choices=NIVELL_C)
#Profissional
    #experiencia = models.CharField('Experiência',max_length=1,choices=ESCOLHA_C,blank=True,null=True)
    nome_emp = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    salario = forms.CharField(required=False,max_length=10, widget=forms.TextInput(attrs={'class':'input-salario'}))
    cargo = forms.CharField(required=False,max_length=80, widget=forms.TextInput(attrs={'class':'input-large'}))
    inicio = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    termino = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    nome_emp1 = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    salario1 = forms.CharField(required=False,max_length=10, widget=forms.TextInput(attrs={'class':'input-salario'}))
    cargo1 = forms.CharField(required=False,max_length=80, widget=forms.TextInput(attrs={'class':'input-large'}))
    inicio1 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    termino1 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    nome_emp2 = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    salario2 = forms.CharField(required=False,max_length=10, widget=forms.TextInput(attrs={'class':'input-salario'}))
    cargo2 = forms.CharField(required=False,max_length=80, widget=forms.TextInput(attrs={'class':'input-large'}))
    inicio2 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    termino2 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
#Informacao ADD
    hora_extra = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'textarea-large'}))
    apres = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'textarea-large'}))
    cursos = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'textarea-large'}))
    portadordef = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    tipo_def = forms.CharField(required=False,widget=forms.Select(choices=DEF_C, attrs={'class':'select-medium'}))
    veiculo = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    tipo_veiculo = forms.CharField(required=False,max_length=50, widget=forms.TextInput(attrs={'class':'input-small'}))
    disponibilidade = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    empregado = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    notebook = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    gravador = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    cameradigital = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
#Redes Sociais
    msn = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    twitter = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    facebook = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    orkut = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    googleplus = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    outrarede = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    
    def clean_email(self):
        if User.objects.filter(
            email=self.cleaned_data['email'],
            ).count():
            raise forms.ValidationError('Ja existe um usuario com este e-mail')

        return self.cleaned_data['email']

    def save(self, commit=False, force_inert=True, force_update=True):
        usuario = super(usuarioForm, self).save()
  
        if commit:
            usuario.save()
  
        return usuario


class ateraruForm(forms.ModelForm):
    class Meta:
        model = usuario
        exclude = ('nascimento', 'email', 'senha',)

#Informa��es Pessoais
    nome = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    nacionalidade = forms.CharField(max_length=40, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    cpf = BRCPFField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cpf'}))
    rg = forms.CharField(max_length=15, required=False, widget=forms.TextInput(attrs={'class':'input-small'}))
    est_Civil = forms.CharField(max_length=1,widget=forms.Select(choices=ESTADOCIVIL_C, attrs={'class':'validate[required] select-medium'}))
    sexo = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=SEXO_CHOICES)
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    telefone2 = BRPhoneNumberField(required=False, widget=forms.TextInput(attrs={'class':'input-small tel'}))
    cep = BRZipCodeField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cep'}))
    site = forms.URLField(required=False, widget=forms.TextInput(attrs={'class':'input-large'}))
    foto = forms.ImageField(required=False)
    cidade = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    estado = forms.ChoiceField(choices = STATE_CHOICES, widget=forms.Select(attrs={'class':'validate[required] select-medium'}))
    rua = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    bairro = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    complemento = forms.CharField(widget=forms.TextInput(attrs={'class':'input-large'}),max_length=255, required=False)

#Interesses Profissionais
    areaes = forms.ModelMultipleChoiceField(queryset=areavaga.objects.all(), widget=CheckboxSelectMultiple(attrs={'class':'validate[required]'}))
    pret_salario = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-medium'}), choices=SALARIO_C)
    cargointeresse = forms.CharField(max_length =50, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    tipoperfil = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=TIPOPERFIL_C)

#Graduacao
    nivel = forms.CharField(required=False, max_length=1,widget=forms.Select(choices=NIVEL_C, attrs={'class':'select-medium'}))
    instituicao = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    ano_conclusao = forms.CharField(required=False,max_length=8, widget=forms.TextInput(attrs={'class':'input-small date2'}))

    nivel1 = forms.CharField(required=False,max_length=1,widget=forms.Select(choices=NIVEL_C, attrs={'class':'select-medium'}))
    instituicao1 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso1 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    ano_conclusao1 = forms.CharField(required=False,max_length=8, widget=forms.TextInput(attrs={'class':'input-small date2'}))

    nivel2 = forms.CharField(required=False,max_length=1,widget=forms.Select(choices=NIVEL_C, attrs={'class':'select-medium'}))
    instituicao2 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso2 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    ano_conclusao2 = forms.CharField(required=False,max_length=8, widget=forms.TextInput(attrs={'class':'input-small date2'}))

    niveli = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}), choices=NIVELLI_C)
    nivele = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}), choices=NIVELLI_C)
    nivelidioma = forms.CharField(required=False,max_length=20, widget=forms.TextInput(attrs={'class':'input-small'}))
    niveloutro = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer), choices=NIVELL_C)
#Profissional
    nome_emp = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    salario = forms.CharField(required=False,max_length=10, widget=forms.TextInput(attrs={'class':'input-salario'}))
    cargo = forms.CharField(required=False,max_length=80, widget=forms.TextInput(attrs={'class':'input-large'}))
    inicio = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    termino = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))

    nome_emp1 = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    salario1 = forms.CharField(required=False,max_length=10, widget=forms.TextInput(attrs={'class':'input-salario'}))
    cargo1 = forms.CharField(required=False,max_length=80, widget=forms.TextInput(attrs={'class':'input-large'}))
    inicio1 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    termino1 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))

    nome_emp2 = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    salario2 = forms.CharField(required=False,max_length=10, widget=forms.TextInput(attrs={'class':'input-salario'}))
    cargo2 = forms.CharField(required=False,max_length=80, widget=forms.TextInput(attrs={'class':'input-large'}))
    inicio2 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))
    termino2 = forms.DateField(required=False, widget=forms.DateTimeInput(attrs={'class':'input-small date'}))

#Informacao ADD
    hora_extra = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'textarea-large'}))
    apres = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'textarea-large'}))
    cursos = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'textarea-large'}))
    portadordef = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    tipo_def = forms.CharField(required=False,widget=forms.Select(choices=DEF_C, attrs={'class':'select-medium'}))
    veiculo = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    tipo_veiculo = forms.CharField(required=False,max_length=50, widget=forms.TextInput(attrs={'class':'input-small'}))
    disponibilidade = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    empregado = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    notebook = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    gravador = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    cameradigital = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
#Pesquisa
    conhecimento = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-large'}), choices=CONHECIMENTO_C)
    conhecimento2 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    pesquisa1 = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-large'}), choices=PESQ_C)
    conhecimento3 = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
#Redes Sociais
    msn = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    twitter = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    facebook = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    orkut = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    googleplus = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))
    outrarede = forms.CharField(required=False,max_length=255, widget=forms.TextInput(attrs={'class':'input-large'}))

    def save(self, commit=False, force_insert=True, force_update=True):
        usuario = super(ateraruForm, self).save()

        if commit:
            usuario.save()

        return usuario

class altempForm(forms.ModelForm):
    class Meta:
        model = empresa
        exclude = ('username', 'senha',)

#Informações Pessoais
    nome = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[minSize[8]] input-large'}))
    email = forms.EmailField(max_length=255, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    cpf = BRCPFField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cpf'}))
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    sexo = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=SEXO_CHOICES)
    atuacao =  forms.CharField(max_length=2,widget=forms.Select(choices=ATUACAO_C, attrs={'class':'validate[required] select-medium'}))
    cargo = forms.CharField(max_length =50, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
#Dados da Empresa
    nome_fantasia = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    razao = forms.CharField(max_length=50, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    cnpj = BRCNPJField(widget=forms.TextInput(attrs={'class':"validate[required] input-small cnpj"}))
    foto = forms.ImageField(required=False)
    telefone1 = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    origem = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices = ORIGEM_C)
    site = forms.URLField(required=False, widget=forms.TextInput(attrs={'class':'input-large'}))
    email1 = forms.EmailField(required=False, max_length=255, widget=forms.TextInput(attrs={'class':'input-medium'}))
    nacionalidade = forms.CharField(max_length=40, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    cep = BRZipCodeField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cep'}))
    estado = forms.ChoiceField(choices = STATE_CHOICES, widget=forms.Select(attrs={'class':'validate[required] select-medium'}))
    cidade = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    endereco = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    bairro = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    complemento = forms.CharField(widget=forms.TextInput(attrs={'class':'input-large'}),max_length=255, required=False)
    ramo = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-medium'}))
    tipodeempresa = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=TIPEMP_C)
    descricao = forms.CharField(widget=forms.Textarea(attrs={'class':'textarea-large'}))
    quantFuncionario = forms.IntegerField(max_value=10000, widget=forms.TextInput(attrs={'class':"validate[required] input-small"}))

    def save(self, commit=False, force_insert=True, force_update=True):
        empresa = super(altempForm, self).save()

        if commit:
            empresa.save()

        return empresa

class FormContato(forms.Form):
    nome = forms.CharField(max_length=50)
    mail = forms.EmailField(label = ('E-mail'),required=False)
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'input-small tel'}))
    assunto = forms.CharField(max_length=50)
    mensagem = forms.Field(widget=forms.Textarea)
    
    def enviar(self):
        titulo = 'Mensagem enviada pelo site'
        destino = 'institutogalaxy@gmail.com'
        texto = """
        Nome: %(nome)s
        E-mail: %(mail)s
        Telefone: %(telefone)s
        Assunto: %(assunto)s
        Mensagem: %(mensagem)s
        """ % self.cleaned_data

        send_mail(
            subject=titulo,
            message=texto,
            from_email=destino,
            recipient_list=[destino],
            )

class vagaForm(forms.ModelForm):
    class Meta:
        model = requisicao

    vaga = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    perfilvaga = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=TIPOPERFIL_C)
    descricao = forms.CharField(widget=forms.Textarea(attrs={'class':'validate[required] textarea-large'}))
    tipovaga = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=TIPOVAGA_C)
    atividade = forms.CharField(max_length=100, widget=forms.Textarea(attrs={'class':'validate[required] textarea-large'}))
    experiencias = forms.CharField(widget=forms.Textarea(attrs={'class':'validate[required] textarea-large'}))
    nivel = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-medium'}),choices=NIVEL_C)
    salario = forms.CharField(max_length=15, widget=forms.TextInput(attrs={'class':'validate[required] input-small'}))
    beneficios =forms.CharField(widget=forms.Textarea(attrs={'class':'validate[required] textarea-large'}))
    regime = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-medium'}), choices=REGIME_C)
    horario = forms.CharField(max_length=15, widget=forms.TextInput(attrs={'class':'validate[required] input-small'}))
    nivelhierarquico = forms.ChoiceField(widget=forms.Select(attrs={'class':'validate[required] select-large'}), choices=NIVELH_C)
    localdetrabalho = forms.CharField(max_length=30, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    quantidade = forms.IntegerField(widget=forms.TextInput(attrs={'class':'validate[required] input-small'}))
    adicionais = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':'validate[required] textarea-large'}))
    etapasselecao = forms.CharField(widget=forms.Textarea(attrs={'class':'validate[required] textarea-large'}))
    dataprocura = forms.DateField(widget=forms.DateTimeInput(attrs={'class':'validate[required] input-small date'}))


    def save(self, commit=True):
        vaga = super(vagaForm, self).save()

        if commit:
            vaga.save()

        return vaga

class SugestaoForm(forms.Form):
    nome = forms.CharField(max_length=50)
    mail = forms.EmailField(label = ('E-mail'),required=False)
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'input-small tel'}))
    assunto = forms.CharField(max_length=50)
    mensagem = forms.Field(widget=forms.Textarea)

    def enviar(self):
        titulo = 'Mensagem enviada pelo site'
        destino = 'galaxycomercial@gmail.com'
        texto = """
        Nome: %(nome)s
        E-mail: %(mail)s
        Telefone: %(telefone)s
        Assunto: %(assunto)s
        Mensagem: %(mensagem)s
        """ % self.cleaned_data

        send_mail(
            subject=titulo,
            message=texto,
            from_email=destino,
            recipient_list=[destino],
            )


class inscricaoForm(forms.ModelForm):
    class Meta:
        model = inscricaocursos

    #Informações Pessoais
    nome = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    nascimento = forms.DateField(widget=forms.DateTimeInput(attrs={'class':'validate[required] input-small date'}))
    email = forms.EmailField(max_length=255, widget=forms.TextInput(attrs={'class':'input-medium validate[required]'}))
    est_Civil = forms.CharField(max_length=1,widget=forms.Select(choices=ESTADOCIVIL_C, attrs={'class':'validate[required] select-medium'}))
    sexo = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=SEXO_CHOICES)
    cpf = BRCPFField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cpf'}))
    telefone = BRPhoneNumberField(widget=forms.TextInput(attrs={'class':'validate[required] input-small tel'}))
    telefone2 = BRPhoneNumberField(required=False, widget=forms.TextInput(attrs={'class':'input-small tel'}))
    cep = BRZipCodeField(widget=forms.TextInput(attrs={'class':'validate[required] input-small cep'}))
    cidade = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    estado = forms.ChoiceField(choices = STATE_CHOICES, widget=forms.Select(attrs={'class':'validate[required] select-medium'}))
    rua = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    bairro = forms.CharField(widget=forms.TextInput(attrs={'class':'validate[required] input-large'}),max_length=255)
    complemento = forms.CharField(widget=forms.TextInput(attrs={'class':'input-large'}),max_length=255, required=False)
    trabalha = forms.ChoiceField(required=False,widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':''}),choices=ESCOLHA_C)
    empresanome = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    cargo = forms.CharField(required=False,max_length=50, widget=forms.TextInput(attrs={'class':'input-small'}))
    brindes = forms.ChoiceField(widget=RadioSelect(renderer=HorizRadioRenderer, attrs={'class':'validate[required]'}), choices=BRINDES_C)
    treinamentos = forms.CharField(required=False, max_length=100, widget=forms.TextInput(attrs={'class':'validate[required] input-large'}))
    treinamentos1 = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    treinamentos2 = forms.CharField(required=False,max_length=100, widget=forms.TextInput(attrs={'class':'input-large'}))
    curso = forms.ModelChoiceField(queryset=curso.objects.all(),widget=forms.Select(attrs={'class':'validate[required]'}))

    def save(self, commit=False, force_insert=True, force_update=True):
        inscricaocursos = super(inscricaoForm, self).save()

        if commit:
            inscricaocursos.save()

        return inscricaocursos